package com.mowh.gof23.creational.patterns.prototype;

import com.mowh.gof23.creational.patterns.prototype.framework.Product;

/**
 * @author mowh1gd
 * @create 2023/10/20 15:36
 */
public class MessageBox implements Product {
    private char decoChar;

    public MessageBox(char decoChar) {
        this.decoChar = decoChar;
    }

    @Override
    public void use(String aString) {
        int length = aString.getBytes().length;
        for (int i = 0; i < length + 4; i++) {
            System.out.print(decoChar);
        }
        System.out.println("");
        System.out.println(decoChar + " " + aString + " " + decoChar);
        for (int i = 0; i < length + 4; i++) {
            System.out.print(decoChar);
        }
        System.out.println("");
    }

    @Override
    public Product createClone() throws CloneNotSupportedException {
        Product p = null;
        p = (Product) clone();
        return p;
    }
}
